<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
	<link rel="stylesheet" type="text/css" href="css/reset.css">
	<link rel="stylesheet" type="text/css" href="css/style4.css">
</head>
<body>
	<input type="button" name="" value="全选" onclick="all_check()">
	<input type="button" name="" value="反选" onclick="opposite()">
	<ul id="main_ul">
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
		<li><input type="checkbox"></li>
	</ul>
</body>

	<script type="text/javascript">
		var main_ul = document.getElementById('main_ul');
		var check_input = main_ul.getElementsByTagName('input');


		function all_check(){
			for (var i = 0; i < check_input.length; i++) {
				check_input[i].checked = true;
			}
		}

		function opposite(){
			for (var i = 0; i < check_input.length; i++) {
				check_input[i].checked = !check_input[i].checked;
			}
		}

	</script>

</html>